package looting;

import impsoft.bots.reflection.GroundItem;
import impsoft.utils.uber.UberScriptUtils;

public class LootItem {
	private String name;
	private int id;
	private int value;
	private boolean stackable;

	public LootItem(String name, int id, int value) {
		this(name, id, value, false);
	}

	public LootItem(String name, int id, int value, boolean stackable) {
		super();
		this.name = name;
		this.id = id;
		this.value = value;
		this.stackable = stackable;
	}

	public String getName() {
		if (stackable || name.contains("(stackable)")) {
			return name.replace("(stackable)", "");
		}

		return name;
	}

	public void setValue(int value) {
		this.value = value;
	}

	public int getId() {
		return id;
	}

	public int getValue() {
		return UberScriptUtils.getPrice(id);
	}

	public boolean isStackable() {
		return stackable;
	}

	public boolean matches(GroundItem gi) {
		return idMatches(gi.getID()) && nameMatches(gi.getName());
	}

	public boolean idMatches(int id) {
		return this.id == id;
	}

	public boolean nameMatches(String name) {
		return getName().equalsIgnoreCase(name);
	}

	@Override
	public String toString() {
		return name + (stackable ? "(stackable)" : "");
	}
}